<template>
  <div>
    <img src="https://img0.baidu.com/it/u=3200238064,331094530&fm=253&fmt=auto&app=138&f=JPEG?w=440&h=564" alt="">
    <p :style="{backgroundColor:strColor}" @click="btn">{{ dogname }}</p>
  </div>
</template>

<script>
export default {
  props:["imgurl", "dogname"],
    name:'app',
  data(){
    return {
      strColor:''
    }
  },
  methods: {
    btn() {
      this.strColor = `rgb(${Math.floor(Math.random() * 256)}, ${Math.floor(
        Math.random() * 256
      )}, ${Math.floor(Math.random() * 256)})`;

      this.$emit("new", this.dogname);
    }
  }
}
</script>

<style scoped>
div {
  width: 200px;
  border: 1px solid black;
  text-align: center;
  float: left;
}

div img {
  width: 100%;
  height: 200px;
}
</style>